import React, { Component } from "react";
import PropTypes from 'prop-types';
import { Input } from 'antd';

export default class Header extends Component {

    // 对接收的props进行：类型、必要性的限制
    static propTypes = {
        addItem: PropTypes.func.isRequired
    }

    handleEnter = (event) => {
       const {addItem} = this.props
       addItem(event.target.value)
    }

    render() {
        return (
            <div>
               <Input onPressEnter={this.handleEnter} placeholder="请输入你的任务名称，按回车键确认"/>
            </div>
        )
    }
}